package date;

import java.util.Calendar;

/**
 * @author DCSGO
 * @version 1.0
 * 第二代日期类
 * Calendar(日历)
 */
public class Date02 {
    public static void main(String[] args) {
        //Calendar 是一个抽象类 所以不能直接实例化
        Calendar cal = Calendar.getInstance();
        System.out.println(cal);
        //java.util.GregorianCalendar[time=1687854670258,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=31,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2023,MONTH=5,WEEK_OF_YEAR=26,WEEK_OF_MONTH=5,DAY_OF_MONTH=27,DAY_OF_YEAR=178,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=31,SECOND=10,MILLISECOND=258,ZONE_OFFSET=28800000,DST_OFFSET=0]

        //Calendar 没有提供格式化的方法或者类 因此要想格式化的输出就需要我们自己去排列组合
        System.out.println(cal.get(Calendar.YEAR) + "-" +
                //月份 + 1 因为 一月对应的是 0
                (cal.get(Calendar.MONTH) + 1) + "-" +
                cal.get(Calendar.DATE) + " " +
                //cal.get(Calendar.DAY_OF_WEEK)+" "+
                cal.get(Calendar.HOUR) + ":" +
                cal.get(Calendar.MINUTE) + ":" +
                cal.get(Calendar.SECOND));//2023-6-27 4:41:37

        System.out.println(cal.get(Calendar.YEAR) + "-" +
                //月份 + 1 因为 一月对应的是 0
                (cal.get(Calendar.MONTH) + 1) + "-" +
                cal.get(Calendar.DATE) + " " +
                //cal.get(Calendar.DAY_OF_WEEK)+" "+
                cal.get(Calendar.HOUR_OF_DAY) + ":" +//24小时制
                cal.get(Calendar.MINUTE) + ":" +
                cal.get(Calendar.SECOND));//2023-6-27 16:47:6
    }
}
